﻿<UserControl x:Class="WeatherClockWidget.FlipClockControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Width="129" Height="142">
    <UserControl.Resources>
        <Storyboard x:Key="FlipAnim">
            <DoubleAnimation Storyboard.TargetName="BgTopRotation" Storyboard.TargetProperty="Angle" From="0" To="180" Duration="0:0:0.5" AccelerationRatio="0.8" Completed="FlipAnim_Completed"/>
            <DoubleAnimation Storyboard.TargetName="RotateTransform" Storyboard.TargetProperty="CenterY" From="-0.5" To="-0.48" Duration="0:0:0.25" AccelerationRatio="0.8" AutoReverse="True"/>
            <DoubleAnimation Storyboard.TargetName="Bg" Storyboard.TargetProperty="Opacity" From="1" To="1" Duration="0:0:0.2" Completed="DummyAnim_Cmpleted"/>
        </Storyboard>
    </UserControl.Resources>
    <Grid>
        <Image Name="Bg" Source="Skins\Sense\FlipAnim\Background\flip_bg.png" Width="129" Height="142" />
        <Image Name="BgRightDigitTop" Source="Skins\Sense\FlipAnim\Digits\0.png" Width="48" Height="83" Margin="51,-9,0,0">
            <Image.Clip>
                <RectangleGeometry>
                    <RectangleGeometry.Rect>
                        <Rect Width="48" Height="39"/>
                    </RectangleGeometry.Rect>
                </RectangleGeometry>
            </Image.Clip>
        </Image>
        <Image Name="BgRightDigitBottom" Width="48" Height="83" Margin="51,-9,0,0">
            <Image.Clip>
                <RectangleGeometry>
                    <RectangleGeometry.Rect>
                        <Rect Width="48" Height="43" Y="40"/>
                    </RectangleGeometry.Rect>
                </RectangleGeometry>
            </Image.Clip>
        </Image>
        <Image Name="BgLeftDigitTop" Width="48" Height="83" Margin="-51,-9,0,0">
            <Image.Clip>
                <RectangleGeometry>
                    <RectangleGeometry.Rect>
                        <Rect Width="48" Height="39"/>
                    </RectangleGeometry.Rect>
                </RectangleGeometry>
            </Image.Clip>
        </Image>
        <Image Name="BgLeftDigitBottom" Width="48" Height="83" Margin="-51,-9,0,0">
            <Image.Clip>
                <RectangleGeometry>
                    <RectangleGeometry.Rect>
                        <Rect Width="48" Height="43" Y="40"/>
                    </RectangleGeometry.Rect>
                </RectangleGeometry>
            </Image.Clip>
        </Image>
        <Image Name="AmPm" Source="Skins\Sense\am.png" Width="20" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="18,85,0,0"/>
        <Viewport3D ClipToBounds="False" Width="111" Height="54" VerticalAlignment="Top" Margin="0,10,0,0">
            <ModelVisual3D>
                <ModelVisual3D.Content>
                    <Model3DGroup>
                        <GeometryModel3D>
                            <GeometryModel3D.Transform>
                                <RotateTransform3D x:Name="RotateTransform" CenterY="-0.5">
                                    <RotateTransform3D.Rotation>
                                        <AxisAngleRotation3D x:Name="BgTopRotation" Axis="1,0,0" Angle="0" />
                                    </RotateTransform3D.Rotation>
                                </RotateTransform3D>
                            </GeometryModel3D.Transform>
                            <GeometryModel3D.Geometry>
                                <!-- Front. -->
                                <MeshGeometry3D
                                    Positions="-1 -1 0, 1 -1 0, 1 1 0, -1 1 0"
                                    TextureCoordinates="0 1, 1 1, 1 0, 0 0" 
                                    Normals="0 0 1  0 0 1  0 0 1  0 0 1"
                                    TriangleIndices="0 1 2, 0 2 3"/>
                            </GeometryModel3D.Geometry>

                            <GeometryModel3D.Material>
                                <MaterialGroup>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush x:Name="TabUp" Stretch="Uniform" Viewbox="0,0,1,1.01" Viewport="0,0,1,1.01">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <TranslateTransform X="0.002" Y="-0.003"/>
                                                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleY="0.97" ScaleX="0.96"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <!-- Digits -->
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush ImageSource="{Binding ElementName=BgRightDigitBottom, Path=Source}"  Stretch="Fill" Viewbox="0,0,1,0.483" Viewport="0,0,1,0.9">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <ScaleTransform ScaleX="0.42" ScaleY="0.388"/>
                                                        <TranslateTransform X="0.508" Y="0.3955"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush ImageSource="{Binding ElementName=BgLeftDigitBottom, Path=Source}" Stretch="Fill" Viewbox="0,0,1,0.483" Viewport="0,0,1,0.9" Opacity="1">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <ScaleTransform ScaleX="0.42" ScaleY="0.388"/>
                                                        <TranslateTransform X="0.063" Y="0.395"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                </MaterialGroup>
                            </GeometryModel3D.Material>

                            <GeometryModel3D.BackMaterial>
                                <MaterialGroup>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush x:Name="TabDown" Stretch="Uniform" Viewbox="0,0,1,1.0" Viewport="0,0,1,1.01">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <TranslateTransform X="0.007" Y="-0.03"/>
                                                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleY="-0.95" ScaleX="0.95"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush x:Name="AmPmBack" Stretch="Uniform">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <TranslateTransform X="-1.9" Y="1.0"/>
                                                        <ScaleTransform CenterX="0.5" CenterY="0.5" ScaleY="-0.17" ScaleX="0.17"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <!-- Digits -->
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush ImageSource="{Binding ElementName=BgRightDigitTop, Path=Source}" Stretch="Fill" Viewbox="0,0.47,1,0.53" Viewport="0,0,1,0.9" Opacity="1">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <ScaleTransform ScaleX="0.419" ScaleY="-0.427"/>
                                                        <TranslateTransform X="0.509" Y="0.763"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush ImageSource="{Binding ElementName=BgLeftDigitTop, Path=Source}" Stretch="Fill" Viewbox="0,0.47,1,0.53" Viewport="0,0,1,0.9" Opacity="1">
                                                <ImageBrush.Transform>
                                                    <TransformGroup>
                                                        <ScaleTransform ScaleX="0.419" ScaleY="-0.427"/>
                                                        <TranslateTransform X="0.063" Y="0.763"/>
                                                    </TransformGroup>
                                                </ImageBrush.Transform>
                                            </ImageBrush>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                </MaterialGroup>
                            </GeometryModel3D.BackMaterial>
                        </GeometryModel3D>

                        <!-- Light source. -->
                        <AmbientLight Color="White" />
                    </Model3DGroup>
                </ModelVisual3D.Content>
            </ModelVisual3D>
            <!-- Camera. -->
            <Viewport3D.Camera>
                <PerspectiveCamera FieldOfView="30" LookDirection="0 0 -1" UpDirection="0 1 0" Position="-0.01 0 3.62"/>
            </Viewport3D.Camera>
        </Viewport3D>
    </Grid>
</UserControl>
